package com.jinmdz.fmis.mapper.mapper;

import org.apache.ibatis.annotations.*;
import com.jinmdz.fmis.mapper.mapper.provider.CremationProvider;
import com.jinmdz.fmis.mapper.entity.CremationEntity;

import java.util.ArrayList;

/**
 * 火化业务表Mapper
 * 
 * @author generator
 * @date 2020-08-23 18:11
 */
public interface CremationMapper {

    /**
     * 增加Cremation
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @InsertProvider(type = CremationProvider.class, method = "insertCremation")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertCremation(@Param("entity") CremationEntity entity);

    /**
     * 删除Cremation
     * 
     * @param id 主键
     * @param modifiedUserId 修改用户外键
     * @param version 版本号
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Update(" update cremation set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForCremation(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改Cremation
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @UpdateProvider(type = CremationProvider.class, method = "updateCremation")
    void updateCremation(@Param("entity") CremationEntity entity);

    /**
     * 查询Cremation实体
     * 
     * @param id 主键
     * @return CremationEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Select(" select id,deleted,business_code,furnace_type_code,furnace_id,as_appointment,appointment_date,appointment_time_segment,reality_start_time,reality_cooling_time,reality_finish_time,cremation_no,process_state_code,as_active,rule_number,rule_unit,rule_code,rule_remark,remark,random_code,charge_id,as_take_ash,ash_handle_type_code,ash_whereabouts_code,as_recognition,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from cremation where id = #{id} and deleted = 0 limit 1 ")
    CremationEntity getCremationById(@Param("id") Integer id);

    /**
     * 查询Cremation列表
     * 
     * @param entity 数据实体
     * @return CremationEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @SelectProvider(type = CremationProvider.class, method = "listCremation")
    ArrayList<CremationEntity> listCremation(@Param("entity") CremationEntity entity);
}